/**
 post获取接口数据
 **/
layui.define(["layer", "jquery"], function (exports) {
    var $ = layui.$;
    var layer = layui.layer;
    var obj = {
        test: function (msg) {
            alert(msg + '111');
        },
        // header：php的header（固定） data:请求数据（json） callback：回调
        option: function (list, name, callback) {
            var option = {};
            //获取一级
            $.each(list, function (k, v) {
                if (name == v.name) {
                    option.id = v.id;
                    option.pid = v.pid;
                    option.name = v.name;
                    option.v = v.v;
                    option.isdel = v.isdel;
                    option.state = v.state;
                    option.created = v.created;
                    option.remarks = v.remarks;
                    option.order_id = v.order_id;
                    option.children = [];
                    return false;
                }
            });
            if(option.id !== undefined){
                //获取二级
                $.each(list, function (k, v) {
                    if(option.id == v.pid){
                        option.children.push(v);
                    }
                });
            }

            return option;
        }
    };

    exports('getOption', obj);
});